<template>
  <el-dialog v-model="obj.visible"
             width="50%"
             :show-close="false"
             style="padding: 0"
             fullscreen
             :close-on-click-modal="false"
             :close-on-press-escape="false"
  >
    <template #header="{ close, titleId, titleClass }">
      <div class="header">
        <span>{{ obj.title }}</span>
        <el-link @click="close" :underline="false">
          <el-icon style="color: white">
            <Close/>
          </el-icon>
        </el-link>
      </div>
    </template>
    <div style="padding: 10px 10px">
      <OrderDetail :order="order_detail"/>
      <el-card shadow="never" style="margin-top:10px;">
        <el-form :model="obj.form" ref="ruleForm" label-width="auto" :rules="obj.rules">
          <el-table :data="obj.form.table_data" border style="margin-bottom: 10px">
            <el-table-column prop="resource_name" label="资源名称"/>
            <el-table-column prop="net_location_text" label="网络位置"/>
            <el-table-column prop="security_domain_text" label="安全分区"/>
            <el-table-column prop="ipaddress" label="IP地址" min-width="150">
              <template #default="scope">
                <el-form-item v-if="obj.form.process_method===1" :prop="`table_data[${scope.$index}].ipaddress`"
                              :rules="obj.rules.ipaddress">
                  <el-input v-model="scope.row.ipaddress" placeholder="请输入有效的IP地址"/>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column prop="netmask" label="掩码" min-width="150">
              <template #default="scope">
                <el-form-item v-if="obj.form.process_method===1" :prop="`table_data[${scope.$index}].netmask`"
                              :rules="obj.rules.netmask">
                  <el-input v-model="scope.row.netmask" placeholder="请输入有效的掩码"/>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column prop="gateway" label="网关" min-width="150">
              <template #default="scope">
                <el-form-item v-if="obj.form.process_method===1" :prop="`table_data[${scope.$index}].gateway`"
                              :rules="obj.rules.gateway">
                  <el-input v-model="scope.row.gateway" placeholder="请输入有效的网关地址"/>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column prop="vlan_id" label="VlanID" min-width="120">
              <template #default="scope">
                <el-form-item v-if="obj.form.process_method===1" :prop="`table_data[${scope.$index}].vlan_id`"
                              :rules="obj.rules.vlan_id">
                  <el-input-number v-model="scope.row.vlan_id" :step="10" :min="1"
                                   :max="4094"></el-input-number>
                </el-form-item>
              </template>
            </el-table-column>
          </el-table>
          <el-form-item v-if="obj.is_edit" label="处理方式" prop="process_method">
            <el-radio-group v-model="obj.form.process_method">
              <el-radio v-for="item in obj.options.process_method" :value="item.value">{{ item.label }}</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="审批意见" prop="remarks">
            <el-col :span="8">
              <el-input v-model="obj.form.remarks" type="textarea" maxlength="100" show-word-limit/>
            </el-col>
          </el-form-item>
          <el-form-item>
            <el-col :span="24">
              <el-button type="primary" @click="obj.doSubmit(ruleForm)" size="large" style="width: 200px;">
                提交
              </el-button>
              <el-button @click="obj.visible=false" size="large" style="width: 200px;">取消</el-button>
            </el-col>
          </el-form-item>
        </el-form>
      </el-card>
    </div>
  </el-dialog>
</template>

<script setup>
import {ref} from "vue";
import OrderDetail from "./OrderDetail.vue";

const ruleForm = ref(null)
const props = defineProps({obj: {}, order_detail: {}})
defineExpose({ruleForm})
</script>

<style scoped>
.header {
  color: #FFFFFF;
  height: 48px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  background-color: rgb(51.2, 126.4, 204);

}

.cell-item {
  display: flex;
  align-items: center;
}


::v-deep(.el-card__header) {
  background-color: #F2F6FC;
  color: black;
  font-weight: bold;
  height: 72px;
}


.horizontal-timeline {
  overflow-x: auto; /* 允许横向滚动（如果内容过多） */
}

.horizontal-timeline ::v-deep(.el-timeline) {
  display: flex;
  flex-direction: row;
  padding: 0;
  margin: 0;
  white-space: nowrap; /* 防止换行 */
}

.horizontal-timeline ::v-deep(.el-timeline-item) {
  flex: 1;
  min-width: 150px; /* 设置最小宽度，防止挤压 */
  padding-right: 20px;
  position: relative;
}

.horizontal-timeline ::v-deep(.el-timeline-item__tail) {
  display: none; /* 隐藏默认的垂直线 */
}

.horizontal-timeline ::v-deep(.el-timeline-item__node) {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
}

.horizontal-timeline ::v-deep(.el-timeline-item__timestamp) {
  text-align: center;
  margin-top: 10px;
}
</style>